home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / prog / mui / modula / demo / muitest.mod < prev   
Text File  |  1996-02-07  |  7KB  |  214 lines

  1. MODULE MuiTest;
  2.  
  3. (*$ LargeVars:=FALSE *)
  4.  
  5. (*
  6. ** This is just a little demo Prg. to show how to use MUI in Modula
  7. ** It has no functions, it just looks good (who cares.... ;-)
  8. ** Please note : There was a little bugfix in this version.
  9. **               Look where the WindowID gets defined - you have
  10. **               to write MakeID("....") instead of ADR("....")
  11. **               then MUI will store your window position!!
  12. **
  13. ** Version : 13.10.1993
  14. **
  15. ** Updated Nov 27, 1995 by Olaf Peters:
  16. **  - does not use MUIOBSOLETE tags any longer
  17. *)
  18.  
  19. IMPORT MD:MuiD;
  20. IMPORT ML:MuiL;
  21. IMPORT MM:MuiMacros;
  22. FROM   MuiMacros  IMPORT set,get,MakeID;
  23. FROM   MuiSupport IMPORT DOMethod, DoMethod, fail;
  24. FROM   SYSTEM     IMPORT TAG, ADR, LONGSET, CAST;
  25. FROM   ExecL      IMPORT Wait;
  26. FROM   UtilityD   IMPORT tagEnd;
  27.  
  28. TYPE
  29.     ShortString = ARRAY[0..3] OF CHAR;
  30.  
  31. CONST
  32.     True  = 1;      (* These are for the set-Macro *)
  33.     False = 0;      (* because set excepts just LONGINT as argument *)
  34.     
  35.     IDbut1= 1;      (* The IDs for the Buttons *)
  36.     IDbut2= 2;
  37.     IDbut3= 3;
  38.     IDbut4= 4;
  39.     IDbut5= 5;
  40.     IDbut6= 6;
  41.  
  42. VAR app,window,bt1,bt2,bt3,bt4,bt5,bt6,Dirs  : MD.APTR;
  43.     signals                                  : LONGSET;
  44.     running                                  : BOOLEAN;
  45.     msg                                      : LONGINT;
  46.     buffer                                   : ARRAY[0..30] OF LONGINT;
  47.     buffer1                                  : ARRAY[0..30] OF LONGINT;
  48.     buffer2                                  : ARRAY[0..30] OF LONGINT;
  49.     buffer3                                  : ARRAY[0..30] OF LONGINT;
  50.  
  51. BEGIN
  52.  
  53.     running := TRUE;
  54.  
  55.     (* Set up the buttons *)
  56.  
  57.     bt1 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("Button 1"), tagEnd));
  58.     bt2 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("B_utton 2"), tagEnd));
  59.     bt3 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("Bu_tton 3"), tagEnd));
  60.     bt4 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("Butt_on 4"), tagEnd));
  61.     bt5 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("Butto_n 5"), tagEnd));
  62.     bt6 := ML.MakeObject(MD.moButton, TAG(buffer1, ADR("_Cancel"), tagEnd));
  63.  
  64.     (* Set up the Volumelist *)
  65.  
  66.     Dirs:= MM.ListviewObject(TAG(buffer1,
  67.                 MD.maListviewList,  MM.VolumelistObject(TAG(buffer2,
  68.                                         MD.maFrame,         MD.mvFrameInputList,
  69.                                         MD.maFrameTitle,    ADR("Magic Volumes"),
  70.                                         tagEnd)),
  71.                 tagEnd));
  72.  
  73.     (* Set up the window *)
  74.  
  75.     window := MM.WindowObject(TAG(buffer,
  76.                     MD.maWindowTitle   , ADR("MUI-Test :-)"),
  77.                     MD.maWindowID      , MakeID("MAIN"),
  78.  
  79.                     MM.WindowContents,
  80.  
  81.                         (* Create an array of Buttons *)
  82.  
  83.                         MM.VGroup(TAG(buffer3,
  84.                             MM.Child, MM.HGroup(TAG(buffer1,
  85.                                     MD.maFrame,         MD.mvFrameGroup,
  86.                                     MD.maFrameTitle,    ADR("Magic Buttons"),
  87.                                     MM.Child, MM.VGroup(TAG(buffer2,MD.maWeight, 20,
  88.                                             MM.Child, bt1,
  89.                                             MM.Child, bt2,
  90.                                             MM.Child, bt3,
  91.                                             tagEnd)),
  92.                                     MM.Child, MM.VGroup(TAG(buffer2,MD.maWeight, 20,
  93.                                             MM.Child, bt4,
  94.                                             MM.Child, bt5,
  95.                                             MM.Child, bt6, (* cancel *)
  96.                                             tagEnd)),
  97.                                     tagEnd)),
  98.  
  99.                             (* Put the Volumelist below them *)
  100.  
  101.                             MM.Child, Dirs,
  102.                             tagEnd)),
  103.                 tagEnd));
  104.  
  105.     (* set up the application object *)
  106.  
  107.     app:=MM.ApplicationObject(TAG(buffer,
  108.                     MD.maApplicationTitle      , ADR("MUITest"),
  109.                     MD.maApplicationVersion    , ADR("V1.0ß"),
  110.                     MD.maApplicationCopyright  , ADR("©1993 by Christian Scholz"),
  111.                     MD.maApplicationAuthor     , ADR("Tochkopf"),
  112.                     MD.maApplicationDescription, ADR("Test the MUI-Magic :-)"),
  113.                     MD.maApplicationBase       , ADR("MUITest"),
  114.  
  115.                     MM.SubWindow, window,
  116.  
  117.             tagEnd));
  118.  
  119.     IF app=NIL THEN fail(app, "failed to create Application !!"); END;
  120.  
  121. (* Set up the notification *)
  122.  
  123.             DoMethod(window,TAG(buffer,
  124.                         MD.mmNotify,MD.maWindowCloseRequest,TRUE,
  125.                         app,2,MD.mmApplicationReturnID,IDbut6
  126.                         ));
  127.  
  128.             DoMethod(bt1,TAG(buffer,
  129.                         MD.mmNotify,MD.maPressed,FALSE,
  130.                         app,2,MD.mmApplicationReturnID,IDbut1
  131.                         ));
  132.  
  133.             DoMethod(bt2,TAG(buffer,
  134.                         MD.mmNotify,MD.maPressed,FALSE,
  135.                         app,2,MD.mmApplicationReturnID,IDbut2
  136.                         ));
  137.  
  138.             DoMethod(bt3,TAG(buffer,
  139.                         MD.mmNotify,MD.maPressed,FALSE,
  140.                         app,2,MD.mmApplicationReturnID,IDbut3
  141.                         ));
  142.  
  143.             DoMethod(bt4,TAG(buffer,
  144.                         MD.mmNotify,MD.maPressed,FALSE,
  145.                         app,2,MD.mmApplicationReturnID,IDbut4
  146.                         ));
  147.  
  148.             DoMethod(bt5,TAG(buffer,
  149.                         MD.mmNotify,MD.maPressed,FALSE,
  150.                         app,2,MD.mmApplicationReturnID,IDbut5
  151.                         ));
  152.  
  153.             DoMethod(bt6,TAG(buffer,
  154.                         MD.mmNotify,MD.maPressed,FALSE,
  155.                         app,2,MD.mmApplicationReturnID,IDbut6
  156.                         ));
  157.  
  158. (* Cycle Chain for Keyboard *)
  159.  
  160.             set(bt1,  MD.maCycleChain, LONGINT(TRUE)) ;
  161.             set(bt2,  MD.maCycleChain, LONGINT(TRUE)) ;
  162.             set(bt3,  MD.maCycleChain, LONGINT(TRUE)) ;
  163.             set(bt4,  MD.maCycleChain, LONGINT(TRUE)) ;
  164.             set(bt5,  MD.maCycleChain, LONGINT(TRUE)) ;
  165.             set(bt6,  MD.maCycleChain, LONGINT(TRUE)) ;
  166.             set(Dirs, MD.maCycleChain, LONGINT(TRUE)) ;
  167.  
  168. (* Main Loop *)
  169.  
  170.             (* Open the window and set first active object
  171.                Here is also shown, how to use True and False in set *)
  172.  
  173.             set(window,MD.maWindowOpen, True);
  174.             set(window,MD.maWindowActiveObject, Dirs);
  175.  
  176.             (* Event Loop *)
  177.  
  178.             signals := LONGSET{} ;
  179.  
  180.             WHILE running DO
  181.  
  182.                         CASE DOMethod(app, TAG(buffer,
  183.                                MD.mmApplicationNewInput, ADR(signals))) OF
  184.  
  185.                         |   MD.mvApplicationReturnIDQuit, IDbut6:
  186.                                     running:=FALSE;
  187.                         |   IDbut1,IDbut2,IDbut3,IDbut4, IDbut5:
  188.                                     fail(app, "Application failed of no reason");
  189.                         ELSE
  190.  
  191.                         END;
  192.  
  193.  
  194.                         IF running AND (signals <> LONGSET{} ) THEN signals:=Wait(signals);
  195.                                                    END;
  196.             END; (* While *)
  197.  
  198.             (* Close window *)
  199.  
  200.             set(window,MD.maWindowOpen, False);
  201.  
  202. (* Shut up *)
  203.  
  204.         fail(app,"");
  205.  
  206. END MuiTest.
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.